﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Practices.CompositeUI;

namespace FireEvent
{
	public partial class Shell : Form
	{
		public Shell()
		{
			InitializeComponent();
		}

		private WorkItem workItem;
		//There are three attributes that can be attached to setters and used for dependency injection in the CAB: [ComponentDependency("FirstComponent1")] [CreateNew]
		[ServiceDependency]
		public WorkItem WorkItem { set { workItem = value; } }

		private void button1_Click(object sender, EventArgs e)
		{
			Publisher publisher = workItem.Items.Get<Publisher>("Publisher");
			publisher.FireMyEvent();
		}

		private void button2_Click(object sender, EventArgs e)
		{
			workItem.EventTopics["MyEvent"].Fire(this, EventArgs.Empty, null, Microsoft.Practices.CompositeUI.EventBroker.PublicationScope.Global);
		}
	}
}
